{php include wl_template('common/header');}
<style>
    td>i{cursor:pointer; display:inline-block; width:100%; height:100%; color:#428bca;}
    .category-caret{display:inline-block; width:20px; margin: 0 10px; text-align:center; cursor:pointer; color:#d9534f;}
    .add.add_level0{cursor:pointer;}
    .scrollLoading{border-radius: 50px;}
</style>
<ul class="nav nav-tabs">
	<li  class="active" ><a href="#">商户分类管理</a></li>
</ul>
<div class="app-content">
    <div class="app-filter">
        <div class="filter-action">
            <a href="{php echo web_url('store/category/edit')}" class="btn btn-primary">添加分类</a>
            <a href="javascript:;" class="btn btn-success js-category-all js-collapse">全部折叠</a>
        </div>
    </div>
    <div class="app-table-list">
        <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th class="text-center" width="10%">分类图片</th>
                            <th class="text-center" width="30%">分类名称</th>
                            <th class="text-center" width="10%">分类ID</th>
                            <th class="text-center" width="10%">开启状态</th>
                            <th class="text-center" width="10%">菜单类型</th>
                            <th class="text-center" width="10%">显示顺序</th>
                            <th class="text-center" width="20%">操作</th>
                        </tr>
                    </thead>
                    <tbody >
                        {loop $categorys  $category}
                            <tr class="text-center">
                                <td class="text-left">
                                    <img class="scrollLoading" src="{php echo tomedia($category['thumb'])}"  height="45" width="45" >
                                </td>
                                <td class="text-left">
                                    <div>
                                        <span>{$category['name']}</span>
                                    </div>
                                    {if $category['state'] == 0}
                                        <div>
                                            <span>
                                                <a href="{php echo web_url('store/category/edit',array('parentid'=>$category['id']))}" class="add add_level1" title="添加子分类" >
                                                    <i class="fa fa-plus-circle"></i>添加子分类
                                                </a>
                                            </span>
                                            <span class="category-caret">
                                                <i class="fa fa-caret-down js-category-down" style="display:none;" pid="{$category['id']}"></i>
                                                <i class="fa fa-caret-up js-category-up" pid="{$category['id']}"></i>
                                            </span>
                                        </div>
                                    {/if}
                                </td>
                                <td>
                                    <label class='label label-warning'>{$category['id']}</label>
                                </td>
                                <td>{php echo tpl_change_status('store/category/changeStatus&id='.$category['id'],$category['enabled'])}</td>
                                <td>
                                    {if $category['state'] == 0}
                                        普通菜单
                                    {else}
                                        外链菜单
                                    {/if}
                                </td>
                                <td>{$category['displayorder']}</td>
                                <td>
                                	<div style="position: relative;display: initial;">
                                        {if Customized::init('storecate1520') > 0}
                                        <a href="javascript:;" data-id="{$category['id']}"  data-url="{php echo h5_url('pages/subPages2/storeClass/storeClass',['id' => $category['id']])}" id="new-js-copy{$category['id']}" class="js-clip btn btn-default btn-sm" >
                                            复制链接
                                        </a>
                                        {else}
                                        <a href="javascript:;" data-id="{$category['id']}"  data-url="{php echo h5_url('pages/mainPages/store/list',['cate_one' => $category['id']])}" id="js-copy{$category['id']}" class="js-clip btn btn-default btn-sm" >
                                            复制链接
                                        </a>
                                        {/if}
                                	</div>
                                    -

                                    {if Customized::init('storecate1520') > 0}
                                    <a href="javascript:;" data-url="pages/subPages2/storeClass/storeClass?id={$category['id']}"  class="btn btn-default btn-sm js-clip">
                                        复制路径
                                    </a>
                                    {else}
                                    <a href="javascript:;" data-url="pages/mainPages/store/list?cate_one={$category['id']}"  class="btn btn-default btn-sm js-clip">
                                        复制路径
                                    </a>
                                    {/if}

                                    -
                                    <a href="{php echo web_url('store/category/edit',array('id'=>$category['id'],'parentid'=>$category['parentid']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改">
                                        编辑
                                    </a>
                                    -
                                    <a href="{php echo web_url('store/category/delete',array('id'=>$category['id']))}"class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="删除">
                                        删除
                                    </a>
                                </td>
                            </tr>
                            {loop $category['children'] $ccategory}
                                <tr class="js-collpase js-child-category text-center" pid="{$category['id']}">
                                    <td><img class="scrollLoading" src="{php echo tomedia($ccategory['thumb'])}" width='45' height="45" style='float:right;'/></td>
                                    <td class="text-left">
                                        <div style="padding-left:50px;height:30px;line-height:30px;background:url('./resource/images/bg_repno.gif') no-repeat -245px -545px;">
                                            {$ccategory['name']}
                                        </div>
                                    </td>
                                    <td>
                                        <label class='label label-default'>{$ccategory['id']}</label>
                                    </td>
                                    <td>{php echo tpl_change_status('store/category/changeStatus&id='.$ccategory['id'],$ccategory['enabled'])}</td>
                                    <td>
                                        {if $ccategory['state'] == 0}
                                            普通菜单
                                        {else}
                                            外链菜单
                                        {/if}
                                    </td>
                                    <td class="text-center">{$ccategory['displayorder']}</td>
                                    <td class="text-center" style="position:relative;">
                                        <a href="javascript:;" data-id="{$ccategory['id']}" data-url="{php echo h5_url('pages/mainPages/store/list',['cate_one' => $category['id'],'cate_two' => $ccategory['id']])}" id="js-copy{$ccategory['id']}" class="btn btn-default btn-sm js-clip" >
                                                复制链接
                                        </a>
                                        -
                                        <a href="javascript:;" data-url="pages/mainPages/store/list?cate_one={$category['id']}&cate_two={$ccategory['id']}"  class="btn btn-default btn-sm js-clip">
                                            复制路径
                                        </a>
                                        -
                                        <a href="{php echo web_url('store/category/edit',array('id'=>$ccategory['id'],'parentid'=>$ccategory['parentid']))}" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改">
                                            编辑
                                        </a>
                                        -
                                        <a href="{php echo web_url('store/category/delete',array('id'=>$ccategory['id']))}"class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="删除">
                                            删除
                                        </a>
                                    </td>
                                </tr>
                            {/loop}
                        {/loop}
                    </tbody>
                </table>
            </div>
	</div>
</div>
<script type="text/javascript">
	//控制显示
	$(function(){
		$('.js-category-all').click(function() {
			if($(this).hasClass('js-collapse')) {
				$('.js-child-category').fadeOut("slow");
				$('.fa-caret-up').hide();
				$('.fa-caret-down').show();
				$(this).text('全部展开').removeClass('js-collapse');
			} else {
				$('.js-child-category').fadeIn("slow");
				$('.fa-caret-up').show();
				$('.fa-caret-down').hide();
				$(this).text('全部折叠').addClass('js-collapse');
			}
		});
		$('.js-category-up').click(function() {
			var parentId = $(this).attr('pid');
			$('tr[pid="'+parentId+'"]').fadeOut("slow");
			$(this).prev().show();
			$(this).hide();
		});
		$('.js-category-down').click(function() {
			var parentId = $(this).attr('pid');
			$('tr[pid="'+parentId+'"]').fadeIn("slow");
			$(this).next().show();
			$(this).hide();
		});
        $('.js-category-all').trigger("click");
	});
</script>
{php include wl_template('common/footer');}